<!--
 * @Author: your name
 * @Date: 2020-02-17 10:19:09
 * @LastEditTime: 2020-08-22 11:23:16
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \boot_vue\src\views\modules\home.vue
 -->
<template>
  <div style="height: 88vh; overflow: hidden;">
    <iframe style="border:none"
            width="100%"
            height="100%"
            v-bind:src="http"></iframe>
  </div>
</template>

<script>
import jq from 'jquery'
// import Cookies from 'js-cookie'
// import jq from '../../../public/js/jquery'
export default {
  components: {
  },
  data: function () {
    return {
      http: '',
      menuId: '',
      singleSign: '',
      urlParam: ''
    }
  },
  mounted () {
    // this.http = localStorage['http']
    this.menuId = localStorage['menuId']
    this.$http.get(`/system/sysPermission/getPermission?id=${this.menuId}`).then(({ data: res }) => {
      if (res.code !== 0) {
        return
      }
      // this.http = res.data.httpAddress
      this.singleSign = res.data.singleSign
      let that = this
      if (this.singleSign === '1') {
        this.urlParam = JSON.parse(res.data.urlParam)
        var url = '/webroot/decision/login/cross/domain'
        jq.ajax({
          url: url, // 单点登录的管理平台报表服务器
          // type: 'get',
          timeout: 5000, // 超时时间（单位：毫秒）
          dataType: 'jsonp', // 跨域采用jsonp方式
          // data: { 'fine_username': 'puzzle2000', 'fine_password': 'A123457s_', validity: -1 },
          data: { 'fine_username': that.urlParam.fine_username, 'fine_password': that.urlParam.fine_password, validity: that.urlParam.validity },
          jsonp: 'callback',
          success: function (ress) {
            // alert('登录成功' + JSON.stringify(ress))
            if (ress.errorCode) {
              window.alert(ress.errorMsg)
            } else {
              that.http = res.data.httpAddress
              // const frameWindow = document.querySelector('#myframe').contentWindow
              // frameWindow.location.reload()
            }
          },
          error: function () {
            alert('超时或服务器其他错误')// 登录失败（超时或服务器其他错误）
          }
        })
      } else {
        this.http = res.data.httpAddress
      }
    })
  },
  methods: {
  }
}
</script>

<style lang="scss" scoped>
</style>
